<script setup lang="ts">
import { $t } from '@/locales';

defineOptions({
  name: 'HolidaySearch'
});

interface HolidaySearchParams {
  holidayName?: string;
  currencyCode?: string;
  holidayDate?: string;
}

interface Emits {
  (e: 'reset'): void;
  (e: 'search'): void;
}

const emit = defineEmits<Emits>();

const model = defineModel<HolidaySearchParams>('model', { required: true });

function reset() {
  emit('reset');
}

function search() {
  emit('search');
}
</script>

<template>
  <ACard :title="$t('common.search')" :bordered="false" class="card-wrapper">
    <AForm :model="model" :label-width="80">
      <ARow :gutter="[16, 16]" wrap>
        <ACol :span="24" :md="12" :lg="6">
          <AFormItem :label="$t('page.manage.holiday.holidayName')" name="holidayName" class="m-0">
            <AInput v-model:value="model.holidayName" :placeholder="$t('page.manage.holiday.form.holidayName')" />
          </AFormItem>
        </ACol>
        <ACol :span="24" :md="12" :lg="6">
          <AFormItem :label="$t('page.manage.holiday.currencyCode')" name="currencyCode" class="m-0">
            <AInput v-model:value="model.currencyCode" :placeholder="$t('page.manage.holiday.form.currencyCode')" />
          </AFormItem>
        </ACol>
        <ACol :span="24" :md="12" :lg="6">
          <AFormItem :label="$t('page.manage.holiday.holidayDate')" name="holidayDate" class="m-0">
            <ADatePicker
              v-model:value="model.holidayDate"
              :placeholder="$t('page.manage.holiday.form.holidayDate')"
              class="w-full"
            />
          </AFormItem>
        </ACol>
        <ACol :span="24" :md="12" :lg="6">
          <AFormItem class="m-0">
            <div class="w-full flex-y-center justify-end gap-12px">
              <AButton @click="reset">
                <template #icon>
                  <icon-ic-round-refresh class="align-sub text-icon" />
                </template>
                <span class="ml-8px">{{ $t('common.reset') }}</span>
              </AButton>
              <AButton type="primary" ghost @click="search">
                <template #icon>
                  <icon-ic-round-search class="align-sub text-icon" />
                </template>
                <span class="ml-8px">{{ $t('common.search') }}</span>
              </AButton>
            </div>
          </AFormItem>
        </ACol>
      </ARow>
    </AForm>
  </ACard>
</template>

<style scoped></style>
